﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace PolePosition.ControlLibrary.Common
{
    public partial class TransparentLabel : Control
    {
        public TransparentLabel()
        {
            InitializeComponent();
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            // do nothing
        }

        private bool m_HasBeenPainted = false;
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!m_HasBeenPainted)
            {
                m_HasBeenPainted = true;
                this.Visible = false;
                this.Parent.Invalidate(this.Bounds);
                this.Parent.Update();
                this.Visible = true;
            }
            else
            {
                m_HasBeenPainted = false;
                SolidBrush _SolidBrush;
                _SolidBrush = new SolidBrush(this.ForeColor);
                e.Graphics.DrawString(this.Text, this.Font, _SolidBrush, 1, 1);
                e.Graphics.Dispose();
            }
        }

        private void TransparentLabel_TextChanged(object sender, EventArgs e)
        {
            this.Refresh();
        }
    }
}
